home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / cwkfpr.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  13KB  |  433 lines

  1.  
  2.  
  3. /*
  4.     GWMON Parallel Ada Monitor for 386/486 PCs   
  5.     Copyright (C) 1993, Charles W. Kann  & Michael Bliss Feldman
  6.                         ckann@seas.gwu.edu mfeldman@seas.gwu.edu
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. */
  22.  
  23. #include "ed.h"
  24.  
  25. #define DISPLAY_ONLY -1
  26. #define PROCESS_WINDOW 1
  27.  
  28. extern void print_setup_help();
  29.  
  30. extern int rr_flag;
  31. extern int rr_nb_max_stmts;
  32.  
  33. static char *speed_choices[] = { "==========", "=========.", "========..",
  34.        "=======...", "======....", "=====.....", "====......", "===.......",
  35.        "==........", "=.........", "" };
  36. static char *small_large[] = { "Small", "Large", "" };
  37. static char *quantum_choices[] = { "1", "2", "3", "4", "5", "10", "25", "50",
  38.                 "100", "500", "" };
  39. static char *profile_choices[] = { "100", "200", "300", "400", "500", "1000", 
  40.                    "2000", "5000", "" };
  41.  
  42. static char *tasking_choices[] = { "Run Til Block", "Round Robin", "" };
  43. static char *delay_choices[] = { "True", "Scaled", "" };
  44. static char *monitor_choices[] = { "Nothing", "Lines", "Exec %", "" };
  45. static char *window_choices[] = { "Four Windows", "Two Windows, Horizonal", 
  46.                                   "Two Windows, Vertical", "One Window", "" };
  47. static char *yes_or_no[] = { "No", "Yes" , ""};
  48.  
  49. CWK_SETUP_SCREEN()
  50. {
  51.     AVL_WIN_PTR w;
  52.     char msg[81];
  53.     int ch;
  54.     int mode, ret_val;
  55.     int save_mon_type;
  56.     int save_window_type;
  57.     long ret_l_val;
  58.  
  59.     w = AVL_MAKE_WINDOW( "Monitor Setup - ESC to continue, ? for help", 
  60.         4,2,22,76, 1, 15);
  61.         _settextposition(1, 3);
  62.         sprintf( msg,"Execution Speed (1-10):        Cycles For Reporting Exec %: " );
  63.         _outtext( msg );
  64.         _settextposition(2, 3);
  65.         sprintf( msg,"Delay Time 1 sec =       cycles      RR Statements:" ); 
  66.         _outtext( msg );
  67.         _settextposition(3, 3);
  68.         sprintf( msg,"Type of Tasking: " ); 
  69.         _outtext( msg );
  70.         _settextposition(4, 3);
  71.         sprintf( msg,"Type of Delay: " ); 
  72.         _outtext( msg );
  73.         _settextposition(5, 3);
  74.         sprintf( msg,"Type of Monitoring: " ); 
  75.         _outtext( msg );
  76.         _settextposition(6, 3);
  77.         sprintf( msg,"Line Trace:          Task Trace: " ); 
  78.         _outtext( msg );
  79.         _settextposition(7, 3);
  80.         sprintf( msg,"Type of Monitor Window: " ); 
  81.         _outtext( msg );
  82.         _settextposition(9, 3);
  83.     sprintf( msg, "Use the up and down arrow keys to select between choices" );
  84.         _outtext( msg );
  85.  
  86.     
  87.     
  88.     mode = DISPLAY_ONLY;
  89.     save_mon_type = monitor_type;
  90.     save_window_type = monitor_window_type;
  91.     
  92.     if ( ( rr_nb_max_stmts < 0 ) && ( rr_nb_max_stmts > 9999 ) ) 
  93.         rr_nb_max_stmts = 0;
  94.  
  95. TOF:    
  96.     ret_val = CWK_Get_Int( mode, 1, 27, 7, &step_rate, print_setup_help );
  97.     if ( step_rate < 0 )
  98.         step_rate = 0;
  99.     if ( step_rate > MAX_DELAY )
  100.         step_rate = MAX_DELAY;
  101.     if ( ret_val == -1 )
  102.         goto LEAVE;
  103.  
  104.         ret_val = CWK_Get_Int( mode, 1, 63, 5, &Exec_Report_Time, print_setup_help );
  105.     if ( ret_val == -1 )
  106.         goto LEAVE;
  107.  
  108.         ret_val = CWK_Get_Int( mode, 2, 22, 5, &seconds_per_tick, print_setup_help );
  109.     if ( ret_val == -1 )
  110.         goto LEAVE;
  111.  
  112.         ret_val = CWK_Get_Int( mode, 2, 59, 5, &rr_nb_max_stmts, print_setup_help );
  113.     if ( ret_val == -1 )
  114.         goto LEAVE;
  115.  
  116.         ret_val = CWK_Get_Choice( mode, 3, 21, 15, &rr_flag, tasking_choices, print_setup_help );
  117.     if ( ret_val == -1 )
  118.         goto LEAVE;
  119.  
  120.         ret_val = CWK_Get_Choice( mode, 4, 19, 10, &type_of_delay, 
  121.             delay_choices, print_setup_help );
  122.     if ( ret_val == -1 )
  123.         goto LEAVE;
  124.  
  125.         ret_val = CWK_Get_Choice( mode, 5, 23, 10, &save_mon_type, 
  126.             monitor_choices, print_setup_help );
  127.     if ( ret_val == -1 )
  128.         goto LEAVE;
  129.  
  130.         ret_val = CWK_Get_Choice( mode, 6, 16, 3, &step_monitor, 
  131.             yes_or_no, print_setup_help );
  132.     if ( ret_val == -1 )
  133.         goto LEAVE;
  134.  
  135.         ret_val = CWK_Get_Choice( mode, 6, 38, 3, &task_step, 
  136.             yes_or_no, print_setup_help );
  137.     if ( ret_val == -1 )
  138.         goto LEAVE;
  139.  
  140.         ret_val = CWK_Get_Choice( mode, 7, 27, 30, &save_window_type, 
  141.             window_choices, print_setup_help );
  142.     if ( ret_val == -1 )
  143.         goto LEAVE;
  144.  
  145.     mode = PROCESS_WINDOW;
  146.     goto TOF;
  147.  
  148. LEAVE:    AVL_DEL_WINDOW( w );
  149.  
  150.     if ( ( save_mon_type != monitor_type ) ||
  151.          ( save_window_type != monitor_window_type ) )
  152.     {
  153.         CWK_STOP_MONITORING();
  154.         monitor_type = save_mon_type;
  155.         monitor_window_type = save_window_type;
  156.         if ( monitor_type == 1 )
  157.         {
  158.             CWK_SETUP_WINDOWS();
  159.             print_status(); 
  160.         }
  161.     }
  162. }
  163.  
  164. /***********************************************************************/
  165. /*    The setup menu when the user first enters the system             */
  166. /***********************************************************************/
  167.  
  168. CWK_FIRST_SETUP()
  169. {
  170.     AVL_WIN_PTR w;
  171.     char msg[81];
  172.     int ch;
  173.     int mode, ret_val;
  174.  
  175.     w = AVL_MAKE_WINDOW( "Initial Setup Menu", 
  176.         4,2,19,76, 1, 15);
  177.         _settextposition(1, 3);
  178.     _outtext( "RETURN moves between options, UP/DOWN ARROWS to select options\n" );
  179.         _settextposition(2, 3);
  180.     _outtext( "ESC when done" );
  181.  
  182.        _settextposition(8, 3);
  183.        _outtext( "GWUMON Copyright (C) 1993, Charles W. Kann & Michael Bliss Feldman \n" );
  184.        _outtext( "  GWUMON comes with ABSOLUTELY NO WARRANTY.\n" );
  185.        _outtext( "  This is free software, and you are welcome to redistribute it\n" );
  186.        _outtext( "  under certain conditions; for details type CTRL_K.\n" );
  187.  
  188.         _settextposition(4, 3);
  189.         sprintf( msg,"Execution Speed          " ); 
  190.         _outtext( msg );
  191.  
  192.         _settextposition(5, 3);
  193.         sprintf( msg,"Exception Tracing -   " ); 
  194.         _outtext( msg );
  195.  
  196.         _settextposition(6, 3);
  197.         sprintf( msg,"Does your program use tasks -  " ); 
  198.         _outtext( msg );
  199.     mode = DISPLAY_ONLY;
  200.  
  201. TOF:    
  202.         ret_val = CWK_Get_Choice( mode, 4, 28, 11, &step_rate, speed_choices, print_setup_help );
  203.     if ( step_rate < 0 )
  204.         step_rate = 0;
  205.     if ( step_rate > MAX_DELAY )
  206.         step_rate = MAX_DELAY;
  207.     if ( ret_val == -1 )
  208.         goto LEAVE;
  209.  
  210.         ret_val = CWK_Get_Choice( mode, 5, 28, 3, &exception_monitor, 
  211.             yes_or_no, print_setup_help );
  212.     if ( ret_val == -1 )
  213.         goto LEAVE;
  214.  
  215.         ret_val = CWK_Get_Choice( mode, 6, 34, 3, &task_monitor, 
  216.             yes_or_no, print_setup_help );
  217.     if ( ret_val == -1 )
  218.         goto LEAVE;
  219.  
  220.     mode = PROCESS_WINDOW;
  221.     goto TOF;
  222.  
  223. LEAVE:    AVL_DEL_WINDOW( w );
  224.  
  225. }
  226.  
  227. /***********************************************************************/
  228. /*    The setup menu when the user uses with sequential monitoring     */
  229. /***********************************************************************/
  230.  
  231. CWK_SEQ_SETUP()
  232. {
  233.     AVL_WIN_PTR w;
  234.     char msg[81];
  235.     int ch;
  236.     int mode, ret_val;
  237.  
  238.     w = AVL_MAKE_WINDOW( "Sequential Monitor Menu", 
  239.         4,2,13,76, 1, 15);
  240.         _settextposition(1, 3);
  241.     _outtext( "RETURN moves between options, UP/DOWN ARROWS to select options\n" );
  242.         _settextposition(2, 3);
  243.     _outtext( "ESC when done" );
  244.  
  245.         _settextposition(4, 3);
  246.         sprintf( msg,"Monitor Window Size     " ); 
  247.         _outtext( msg );
  248.  
  249.         _settextposition(5, 3);
  250.        sprintf( msg,"When to Pause Execution:   " ); 
  251.         _outtext( msg );
  252.  
  253.         _settextposition(6, 3);
  254.        sprintf( msg,"      As Program Enter/Exits Procedure - " );
  255.         _outtext( msg );
  256.  
  257.         _settextposition(7, 3);
  258.        sprintf( msg,"      As Each Line Of Code Is Executed - " );
  259.         _outtext( msg );
  260.  
  261.     mode = DISPLAY_ONLY;
  262. TOF:    
  263.         ret_val = CWK_Get_Choice( mode, 4, 28, 6, &Large_Monitor, small_large, 
  264.             print_setup_help );
  265.     if ( ret_val == -1 )
  266.         goto LEAVE;
  267.  
  268.         ret_val = CWK_Get_Choice( mode, 6, 45, 3, &task_step, 
  269.             yes_or_no, print_setup_help );
  270.     if ( ret_val == -1 )
  271.         goto LEAVE;
  272.  
  273.         ret_val = CWK_Get_Choice( mode, 7, 45, 3, &step_monitor, 
  274.             yes_or_no, print_setup_help );
  275.     if ( ret_val == -1 )
  276.         goto LEAVE;
  277.  
  278.  
  279.     mode = PROCESS_WINDOW;
  280.     goto TOF;
  281.  
  282. LEAVE:    AVL_DEL_WINDOW( w );
  283.  
  284.     monitor_window_type = 3;
  285. }
  286.  
  287. /***********************************************************************/
  288. /*    The setup menu when the user uses with sequential monitoring     */
  289. /***********************************************************************/
  290.  
  291. CWK_TASK_SETUP()
  292. {
  293.     AVL_WIN_PTR w;
  294.     char msg[81];
  295.     int ch;
  296.     int mode, ret_val;
  297.         int choice;
  298.     int save_window_type;
  299.     int save_mon_type;
  300.  
  301.     w = AVL_MAKE_WINDOW( "Task Monitor Menu", 
  302.         2,2,24,76, 1, 15);
  303.         _settextposition(1, 3);
  304.     _outtext( "RETURN moves between options, UP/DOWN ARROWS to select options\n" );
  305.         _settextposition(2, 3);
  306.     _outtext( "ESC when done" );
  307.  
  308.         _settextposition(4, 3);
  309.         sprintf( msg,"General Information   " ); 
  310.         _outtext( msg );
  311.  
  312.         _settextposition(5, 3);
  313.        sprintf( msg,"    What do you want to Monitor - " );
  314.         _outtext( msg );
  315.  
  316.         _settextposition(6, 3);
  317.        sprintf( msg,"    Type of delay -  " );
  318.         _outtext( msg );
  319.  
  320.         _settextposition(7, 3);
  321.        sprintf( msg,"    Tasking Model - " );
  322.         _outtext( msg );
  323.  
  324.         _settextposition(8, 3);
  325.        sprintf( msg,"    If Round Robin : P Code statments per quantum - " );
  326.         _outtext( msg );
  327.  
  328.         _settextposition(10, 3);
  329.        sprintf( msg,"If monitoring lines as they are executed: " );
  330.         _outtext( msg );
  331.  
  332.         _settextposition(11, 3);
  333.        sprintf( msg,"    Type of Monitor Window - " );
  334.         _outtext( msg );
  335.  
  336.         _settextposition(12, 3);
  337.        sprintf( msg,"    When to Pause Execution:   " ); 
  338.         _outtext( msg );
  339.  
  340.         _settextposition(13, 3);
  341.        sprintf( msg,"          As Program Enter/Exits Procedure - " );
  342.         _outtext( msg );
  343.  
  344.         _settextposition(14, 3);
  345.        sprintf( msg,"          As Each Line Of Code Is Executed - " );
  346.         _outtext( msg );
  347.  
  348.         _settextposition(15, 3);
  349.        sprintf( msg,"If monitoring execution pct (Profiling Program):" );
  350.         _outtext( msg );
  351.  
  352.         _settextposition(16, 3);
  353.        sprintf( msg,"    Number of P-code statements between profile - " );
  354.         _outtext( msg );
  355.  
  356.     mode = DISPLAY_ONLY;
  357.     save_window_type = monitor_window_type;
  358.     save_mon_type = monitor_type;
  359. TOF:    
  360.         ret_val = CWK_Get_Choice( mode, 5, 40, 6, &save_mon_type, 
  361.             monitor_choices, print_setup_help );
  362.     if ( ret_val == -1 )
  363.         goto LEAVE;
  364.  
  365.         ret_val = CWK_Get_Choice( mode, 6, 25, 6, &type_of_delay, 
  366.             delay_choices, print_setup_help );
  367.     if ( ret_val == -1 )
  368.         goto LEAVE;
  369.  
  370.         ret_val = CWK_Get_Choice( mode, 7, 25, 15, &rr_flag, 
  371.             tasking_choices, print_setup_help );
  372.     if ( ret_val == -1 )
  373.         goto LEAVE;
  374.  
  375.     if ( rr_flag == 1 )
  376.     {
  377.         choice = 1;
  378.             ret_val = CWK_Get_Choice( mode, 8, 56, 5, &choice, 
  379.             quantum_choices, print_setup_help );
  380.         rr_nb_max_stmts = atoi( quantum_choices[choice] );
  381.         if ( ret_val == -1 )
  382.             goto LEAVE;
  383.     }
  384.  
  385.     if ( save_mon_type == 1 )
  386.          {
  387.         ret_val = CWK_Get_Choice( mode, 11, 32, 30, &save_window_type, 
  388.             window_choices, print_setup_help );
  389.         if ( ret_val == -1 )
  390.             goto LEAVE;
  391.  
  392.             ret_val = CWK_Get_Choice( mode, 13, 50, 3, &task_step, 
  393.             yes_or_no, print_setup_help );
  394.         if ( ret_val == -1 )
  395.             goto LEAVE;
  396.  
  397.             ret_val = CWK_Get_Choice( mode, 14, 50, 3, &step_monitor, 
  398.             yes_or_no, print_setup_help );
  399.         if ( ret_val == -1 )
  400.             goto LEAVE;
  401.     }
  402.  
  403.     if ( save_mon_type == 2 )
  404.          {
  405.         choice = 1;
  406.             ret_val = CWK_Get_Choice( mode, 16, 58, 5, &choice, 
  407.             profile_choices, print_setup_help );
  408.         Exec_Report_Time = atoi( profile_choices[choice] );
  409.         if ( ret_val == -1 )
  410.             goto LEAVE;
  411.     }
  412.  
  413.     mode = PROCESS_WINDOW;
  414.     goto TOF;
  415.  
  416. LEAVE:    AVL_DEL_WINDOW( w );
  417.  
  418.     if ( ( save_mon_type != monitor_type ) ||
  419.          ( save_window_type != monitor_window_type ) )
  420.     {
  421.         CWK_STOP_MONITORING();
  422.         monitor_type = save_mon_type;
  423.         monitor_window_type = save_window_type;
  424.     }
  425.  
  426.     if ( monitor_type == 1 )
  427.     {
  428.         CWK_SETUP_WINDOWS();
  429.         print_status(); 
  430.     }
  431.  
  432. }
  433.